//
//  LoanSearchView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/29.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class LoanSearchView: UIView {
    
    var number : String! {
        didSet{
            numberLabel.text = "为您找到 " + number + " 个产品"
            numberLabel.attributedText = numberLabel.text?.setTextColor(color: UIColor.red, ranStr: number)
        }
    }

    fileprivate let numberLabel = UILabel() //数量
    let searchView = UITextField.init(Width: 10) //搜索框
    let searchBtn = UIButton() //搜索按钮
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.backgroundColor = UIColor.verifyColor()
        
        numberLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        numberLabel.textAlignment = .center
        self.addSubview(numberLabel)
        
        searchView.backgroundColor = UIColor.white
        searchView.placeholder = inputSearchText
        searchView.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(searchView)
        
        searchBtn.layer.contents = UIImage.init(named: "search")?.cgImage
        self.addSubview(searchBtn)
        
        searchBtn.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(RATIO(maxNum: -10))
            make.centerY.equalToSuperview()
            make.width.height.equalTo(RATIO_H(maxNum: 30))
        }
        
        searchView.snp.makeConstraints { (make) in
            make.right.equalTo(searchBtn.snp.left).offset(RATIO(maxNum: -10))
            make.height.equalTo(30)
            make.centerY.equalTo(searchBtn)
            make.width.equalTo(RATIO(maxNum: 150))
        }
        
        numberLabel.snp.makeConstraints { (make) in
            make.right.equalTo(searchView.snp.left)
            make.left.equalToSuperview()
            make.centerY.height.equalTo(searchView)
        }
        
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    

}
